import request from '@/utils/request'
import Qs from 'qs'

export function listOrder(query) {
  return request({
    url: '/order/ilist',
    method: 'post',
    data: query,
    paramsSerializer: function(params) {
      return Qs.stringify(params, { arrayFormat: 'repeat' })
    }
  })
}

export function detailOrder(id) {
  return request({
    url: '/order/idetail/',
    method: 'get',
    params: { id }
  })
}

// 发货
export function shipOrder(data) {
  return request({
    url: '/order/iupdate',
    method: 'post',
    data
  })
}

export function refundOrder(data) {
  return request({
    url: '/order/refund',
    method: 'post',
    data
  })
}

export function replyComment(data) {
  return request({
    url: '/comment/reply',
    method: 'get',
    params: { 'commentId': data.commentId, 'content': data.content }
  })
}

export function listChannel(id) {
  return request({
    url: '/order/channel',
    method: 'get'
  })
}

// 退款
export function drawBackInfo(orderCancel) {
  return request({
    url: '/orderCancel/idetail',
    method: 'post',
    data: orderCancel
  })
}

// 同意
export function orderConfirm(orderCancel) {
  return request({
    url: '/orderCancel/confirm',
    method: 'post',
    data: orderCancel
  })
}

// 拒绝
export function orderRefuse(orderCancel) {
  return request({
    url: '/orderCancel/refuse',
    method: 'post',
    data: orderCancel
  })
}
